import * as uuid from 'uuid';
import { SubHistory } from './types';

type CreateLineParams = {
  text: string;
  visible?: boolean;
  type: SubHistory['type']
}

// 创建新的一行
const createNewLine = (params: CreateLineParams) => {
  return { id: uuid.v4(), ...params } as SubHistory;
}

// 创建文本
export const createNewText = (visible = false, text = '') => {
  return createNewLine({ type: 'text', visible, text });
}

// 创建产品
export const createNewProduct = (id: string, visible = false) => {
  return createNewLine({ type: 'product', visible, text: '' });
}